<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>父传子</title>
    <script src="./js/vue2.js"></script>
</head>

<body>
    <div id="app">
        <father></father>

    </div>
    <template id='father'>
        <div>
            <p>今天我决定告诉我儿子，他是{{type}}</p>
            <son :mytype="type"></son>
        </div>

    </template>
    <template id="son">
        <p>今天我爸爸告诉我,我是{{mytype}}</p>

    </template>
</body>
<script>
    Vue.component('father', {
        template: "#father",
        data(){
            return {
                fname: 'father',
                type: '富二代'
            }
        },

        components:{
            'son':{
                template: '#son',
                props: ['mytype'],
                data() {
                    return {
                        sname: 'son',
                    }
                }
            }
        }
    })
    var vm = new Vue({
        el: "#app",
        data: {

        }
    })
</script>

</html>